package com.softmaker.service;

import com.softmaker.entity.Product;
import com.softmaker.entity.Video;
import com.softmaker.repository.ProductRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class ProductService {
    @Autowired
    private ProductRepository repository;
    public Product addProduct(Product product)  {
        product.setId(UUID.randomUUID().toString());
        return repository.save(product);
    }
    public List<Product> listProduct() {
        return repository.findAll();
    }
    public Product findProduct(String name){
        return repository.findProductByName(name);
    }
    public Product updProduct(Product product){
        return repository.save(product);
    }
    public Product findProductByPhoto(String photo){
        return repository.findProductByPhoto(photo);
    }
}
